package com.gitee.magic.framework.head.converter;

import com.gitee.magic.core.converter.AbstractConverterEditor;
import com.gitee.magic.core.utils.GzipComperssedUtils;

/**
 * 解压缩转写器
 * @author start
 *
 */
public class StringGzipConverterEditor extends AbstractConverterEditor<String> {

	public StringGzipConverterEditor(Class<?> prototype) {
		super(prototype);
	}

	@Override
	public void restore(Object value) {
		if (value != null) {
			setValue(new String(GzipComperssedUtils.decompressed(String.valueOf(value))));
		}
	}

	@Override
	public String converter() {
		if (getValue() == null) {
			return null;
		}
		return GzipComperssedUtils.compressed(String.valueOf(getValue()));
	}

}
